<html>
<head><meta charset="utf-8"><title>current_exe() v.s. argv[0] · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/current_exe().20v.2Es.2E.20argv.5B0.5D.html">current_exe() v.s. argv[0]</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225148576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/current_exe%28%29%20v.s.%20argv%5B0%5D/near/225148576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/current_exe().20v.2Es.2E.20argv.5B0.5D.html#225148576">(Feb 04 2021 at 11:43)</a>:</h4>
<p>Can the first item of <code>std::env::args()</code> differ from <code>std::env::current_exe()</code>? Can either of them be a relative path?</p>



<a name="225149274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/current_exe%28%29%20v.s.%20argv%5B0%5D/near/225149274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/current_exe().20v.2Es.2E.20argv.5B0.5D.html#225149274">(Feb 04 2021 at 11:52)</a>:</h4>
<p>Yes, the calling program can use any value for <code>argv[0]</code>.</p>



<a name="225149899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/current_exe%28%29%20v.s.%20argv%5B0%5D/near/225149899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/current_exe().20v.2Es.2E.20argv.5B0.5D.html#225149899">(Feb 04 2021 at 12:00)</a>:</h4>
<p><code>current_exe</code> is also not supported on every platform, there's a lot that always return an error.</p>



<a name="225154459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/current_exe%28%29%20v.s.%20argv%5B0%5D/near/225154459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/current_exe().20v.2Es.2E.20argv.5B0.5D.html#225154459">(Feb 04 2021 at 12:50)</a>:</h4>
<p>It is also the case that current_exe will (on Linux at least) give you canonicalized path, argv[0] may be e.g. a symlink</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>